package pro.shushi.pamirs.hr.api.model.eam;

import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxDetail;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxForm;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTable;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.hr.api.enums.BooleanConstantEnum;
import pro.shushi.pamirs.hr.api.enums.eam.MmdTypeEnum;
import pro.shushi.pamirs.hr.api.model.eam.common.AbstractOrgBaseModel;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.IdModel;

import java.math.BigDecimal;

// 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
@UxForm(grid = 3)
@UxDetail(grid = 3)
@Model.model(BsMtoolMd.MODEL_MODEL)
@Model(displayName = "工装型号",labelFields = {"mmdCode","mmdName"})
@Model.Advanced(table="bs_mtool_md",unique = {"orgCode, mmdCode"})
public class BsMtoolMd extends AbstractOrgBaseModel {

    public static final String MODEL_MODEL = "hr.simple.bsMtoolMd";

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "组织编码", required = true)
    private String orgCode;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "工装型号编码", required = true)
    public String mmdCode;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "工装型号名称", required = true)
    public String mmdName;

    @Field(displayName = "工装分类编码")
    public String mttypeCode;

    @Field.Enum(size='4')
    @Field(displayName = "特殊分类", required = true,defaultValue = "0")
    public MmdTypeEnum mmdType;

    // ---------- 平行表bsMtoolMdNr start ----------------------
    //平行表的配置方式以及平行表字段的显示隐藏
    @Field.one2one
//    @Field.Relation(relationFields = {"bsMtoolMdNrId"}, referenceFields = {"id"})
    @Field.Relation(relationFields = {"orgCode","mmdCode"}, referenceFields = {"orgCode","mmdCode"})
    @Field(displayName = "模治具属性", summary = "模治具属性",invisible = true)
//    @UxForm.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'MTOOL'"))
//    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'MTOOL'"))
    private BsMtoolMdNr bsMtoolMdNr;

//    @Field.Integer
//    @Field(displayName = "模治具属性ID", invisible = true)
//    private Long bsMtoolMdNrId;

    @Field.Money(M=20,D=6)
    @Field.Related(related = {"bsMtoolMdNr", "loadProdQty"})
    @Field(displayName = "装载产品数量")
    @UxTable.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'MTOOL'"))
    @UxForm.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'MTOOL'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'MTOOL'"))
    public BigDecimal loadProdQty;

    // ---------- 平行表bsMtoolMdNr end ----------------------

    // ---------- 平行表BsMtoolMdStencil  start ----------------------
    //测试以联合主键关联
    @Field.one2one
    @Field.Relation(relationFields = {"orgCode","mmdCode"}, referenceFields = {"orgCode","mmdCode"})
    @Field(displayName = "工装钢网属性表", summary = "工装钢网属性表",invisible = true)
    private BsMtoolMdStencil bsMtoolMdStencil;


    @Field.Money(M=20,D=6)
    @Field.Related(related = {"bsMtoolMdStencil", "stdMinTension"})
    @Field(displayName = "测试点最小张力值",defaultValue = "0")
    @UxTable.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxForm.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    public BigDecimal stdMinTension;

    @Field.Money(M=20,D=6)
    @Field.Related(related = {"bsMtoolMdStencil", "stdMaxTension"})
    @Field(displayName = "测试点最大张力值",defaultValue = "0")
    @UxTable.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxForm.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    public BigDecimal stdMaxTension;

    @Field.Money(M=20,D=6)
    @Field.Related(related = {"bsMtoolMdStencil", "stdAngleMax"})
    @Field(displayName = "四角间张力偏差上限值",defaultValue = "0")
    @UxTable.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxForm.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    public BigDecimal stdAngleMax;

    @Field.Money(M=20,D=6)
    @Field.Related(related = {"bsMtoolMdStencil", "stdAllDiff"})
    @Field(displayName = "四角与中心点张力偏差上限值",defaultValue = "0")
    @UxTable.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxForm.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    public BigDecimal stdAllDiff;

    @Field.Money(M=20,D=6)
    @Field.Related(related = {"bsMtoolMdStencil", "mdcOnTime"})
    @Field(displayName = "上线时效上限(小时)",defaultValue = "0")
    @UxTable.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxForm.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    public BigDecimal mdcOnTime;

    // ---------- 平行表BsMtoolMdStencil  end ----------------------


    @Field(displayName = "单位")
    public String munit;

    @Field(displayName = "默认仓库编码")
    public String defStoreCode;

    @Field(displayName = "默认储位编码")
    public String defStorelocCode;

    @Field.Integer
    @Field(displayName = "保养预警使用次数", required = true,defaultValue = "0")
    public Integer ukWarnTimes;

    @Field.Integer
    @Field(displayName = "提前保养预警使用次数", required = true,defaultValue = "0")
    public Integer fwUkWarnTimes;

    @Field.Integer
    @Field(displayName = "保养预警使用天数", required = true,defaultValue = "0")
    public Integer ukWarnDays;

    @Field.Integer
    @Field(displayName = "提前保养预警使用天数", required = true,defaultValue = "0")
    public Integer fwUkWarnDays;

    @Field.Enum(size='1')
    @Field(displayName = "工装启用领用与归还", required = true, defaultValue = "n")
    public BooleanConstantEnum isMtoolRcvtn;

    @Field.Enum(size='1')
    @Field(displayName = "工装启用日点检", required = true, defaultValue = "n")
    public BooleanConstantEnum isMtoolChk;

    // TODO:
    @Field.Enum(size='1')
    @Field(displayName = "需校准", required = true, defaultValue = "n")
    public BooleanConstantEnum needAdjust;

    @Field.Integer
    @Field(displayName = "内部校准提前预警天数",defaultValue = "0")
    @UxForm.FieldWidget(@UxWidget(readonly = "activeRecord.needAdjust != 'Y'"))
    @UxDetail.FieldWidget(@UxWidget(readonly = "activeRecord.needAdjust != 'Y'"))
    public Integer iadjWarnDay;

    @Field.Integer
    @Field(displayName = "内部校准间隔天数",defaultValue = "0")
    @UxForm.FieldWidget(@UxWidget(readonly = "activeRecord.needAdjust != 'Y'"))
    @UxDetail.FieldWidget(@UxWidget(readonly = "activeRecord.needAdjust != 'Y'"))
    public Integer iadjExpDay;

    @Field.Money(M=20,D=6)
    @Field(displayName = "单价（RMB）")
    public BigDecimal price;

    @Field.Enum(size='1')
    @Field(displayName = "启用", required = true, defaultValue = "y")
    public BooleanConstantEnum isValid;

    @Field.Text
    @Field(displayName = "备注")
    private String remark;


}
